<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
    if(isset($_GET["table"])) {$table = $_GET["table"];} else{$table = "";}
    if(isset($_GET["ligne"])) {$ligne = $_GET["ligne"];} else{$ligne = "";}
    
    require_once '../include/class.pdoSio.inc.php';
    
    if($table == "experience_prof") {
        $pdo = PdoSio::getPdoSio();
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_experience_prof WHERE id_experience_prof = ".$ligne);
        $etudiants = $pdo->requeteAction("DELETE FROM cv_experience_prof WHERE id_experience_prof = ".$ligne);
    } elseif ($table == "formation") {
        $pdo = PdoSio::getPdoSio();
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_formation WHERE id_formation = ".$ligne);
        $etudiants = $pdo->requeteAction("DELETE FROM cv_formation WHERE id_formation = ".$ligne);
    } elseif ($table == "informatique") {
        $pdo = PdoSio::getPdoSio();
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_informatique WHERE id_informatique = ".$ligne);
        $etudiants = $pdo->requeteAction("DELETE FROM cv_informatique WHERE id_informatique = ".$ligne);
    } elseif ($table == "interet") {
        $pdo = PdoSio::getPdoSio();
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_interet WHERE id_interet = ".$ligne);
        $etudiants = $pdo->requeteAction("DELETE FROM cv_interet WHERE id_interet = ".$ligne);
    } elseif ($table == "langue") {
        $pdo = PdoSio::getPdoSio();
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_langue WHERE id_langue = ".$ligne);
        $etudiants = $pdo->requeteAction("DELETE FROM cv_langue WHERE id_langue = ".$ligne);
    } else {
        $pdo = PdoSio::getPdoSio();
        $unEtudiant = $pdo->requeteSelection("SELECT id_utilisateur FROM cv_photo WHERE id_cv_photo = ".$ligne);
        $etudiants = $pdo->requeteAction("DELETE FROM cv_photo WHERE id_cv_photo = ".$ligne);
    }
    header("Location: ../index.php?uc=cv&action=visualiser&id=".$unEtudiant[0]["id_utilisateur"]."&table=".$table);

